{extend name="layout/layout" /}

{block name="pagecss"}
<style>
    #upload-image img {
        width: 100px;
        height: 100px;
        cursor: pointer;
        border: 1px solid #ccc;
    }
</style>
{/block}

{block name="content"}
<div class="row">
    <div class="col-md-12">
        <div class="portlet light">
            <div class="portlet-title">
                <div class="caption">
                    <i class="icon-share font-dark"></i>
                    <span class="caption-subject font-dark bold uppercase"> 编辑</span>
                </div>
                <div class="actions">
                    <a class="btn btn-circle btn-icon-only btn-default fullscreen" href="javascript:;" data-original-title="" title=""> </a>
                </div>
            </div>
            <div class="portlet-body">
                <form class="form-horizontal" method="post">
                    <div class="form-body">
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        所属类目
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <p class="form-control-static"> {$typeName} </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        农作物名称
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" placeholder="名称，最多40字" id="name" maxlength="40" data-required="1" name="name" value="{$info.name}" required>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        汉语拼音
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" id="pinyin" maxlength="80" data-required="1" name="pinyin" value="{$info.pinyin}" required>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        别称
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" placeholder="多个别称以英文逗号（,）分隔" id="nickname" maxlength="40" data-required="1" name="nickname" value="{$info.nickname}" required>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        图片
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <div id="upload-image">
                                            <span id="upload-btn" data-multi="false">
                                                <input type="hidden" class="form-control" id="imgUrl" data-required="1" name="imgUrl" value="{$info.imgUrl}">
                                                <img src="{$info.imgUrl ?: '__STATIC__/admin/img/default.png'}" alt="图片上传" style="width: 100px;height: 100px;" />
                                            </span>
                                        </div>
                                        <span class="help-block"> (建议尺寸：220*220) </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        物候期
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9" id="phenological">
                                        <button type="button" class="btn btn-success addPhenological-btn" style="margin-bottom: 10px;">
                                            <i class="fa fa-plus"></i> 点击添加
                                        </button>

                                        <div class="list-group phenological-group">
                                            {php}$phenologicalList = explode(',', $info['phenological']);{/php}
                                            {foreach name="phenologicalList" item="phenological" key="phenologicalKey"}
                                            <div class="row group-div" {if condition="($phenologicalKey > 0)"}style="margin-top: 10px;"{/if}>
                                                <div class="col-md-6">
                                                    <input type="text" class="form-control phenological" name="phenological" maxlength="60" placeholder="" value="{$phenological}" autocomplete="off">
                                                </div>
                                                {if condition="($phenologicalKey > 0)"}
                                                <div class="col-md-1">
                                                    <button type="button" class="btn btn-danger remove-btn"><i class="fa fa-close"></i></button>
                                                </div>
                                                {/if}
                                            </div>
                                            {/foreach}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        农事项目
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9" id="farmingProject">
                                        <button type="button" class="btn btn-success addFarmingProject-btn" style="margin-bottom: 10px;">
                                            <i class="fa fa-plus"></i> 点击添加
                                        </button>

                                        <div class="list-group farmingProject-group">
                                            {php}$farmingProjectList = explode(',', $info['farmingProject']);{/php}
                                            {foreach name="farmingProjectList" item="farmingProject" key="farmingProjectKey"}
                                            <div class="row group-div" {if condition="($farmingProjectKey > 0)"}style="margin-top: 10px;"{/if}>
                                                <div class="col-md-6">
                                                    <input type="text" class="form-control farmingProject" name="farmingProject" maxlength="60" placeholder="" value="{$farmingProject}" autocomplete="off">
                                                </div>
                                                {if condition="($farmingProjectKey > 0)"}
                                                <div class="col-md-1">
                                                    <button type="button" class="btn btn-danger remove-btn"><i class="fa fa-close"></i></button>
                                                </div>
                                                {/if}
                                            </div>
                                            {/foreach}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-9">
                                <div class="form-group">
                                    <label class="control-label col-md-3">
                                        排序
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9">
                                        <input type="text" class="form-control" maxlength="4" name="sorting" value="{$info.sorting}" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <input type="hidden" name="id" value="{$info.id}">
                        <input type="hidden" name="typeId" value="{$typeId}">
                        <hr />
                        <div class="row">
                            <div class="form-actions">
                                <div class="col-md-offset-2 col-md-10">
                                    <button type="button" class="btn blue save-btn">
                                        保存 <i class="fa fa-floppy-o"></i>
                                    </button>
                                    <button type="button" class="btn default" onclick="history.go(-1);">
                                        返回 <i class="fa fa-mail-forward"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<input type="hidden" class="token_url" value="{:url('admin/Image/token')}">
<input type="hidden" class="record_url" value="{:url('admin/Image/record')}">
<input type="hidden" class="delimage_url" value="{:url('admin/Image/delete')}">

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/editpost')}">
{/block}

{block name="pagescript"}
<script src="__STATIC__/admin/js/qiniu/plupload.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniu.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/custom.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniuConfig.js" type="text/javascript"></script>

<script src="__STATIC__/admin/pages/js/uploadfile.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/crop.js" type="text/javascript"></script>
{/block}